//
//  PPNavigationViewController.m
//  PPDL
//
//  Created by 王洋 on 2019/8/5.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "PPNavigationViewController.h"

@interface PPNavigationViewController ()<UINavigationControllerDelegate>

@end

@implementation PPNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.delegate = self;

    [self hiddenNavigationBarBottomLine];
}


//2.去掉文字
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
    self.navigationBar.barStyle = UIStatusBarStyleDefault;
    [self.navigationBar setTintColor:UIColorHex(0x333333)];
    viewController.navigationItem.backBarButtonItem = item;
    [super pushViewController:viewController animated:animated];
}


- (void)hiddenNavigationBarBottomLine {
    if (@available(iOS 11.0, *)) {
        [self.navigationBar setShadowImage:[UIImage new]];
    }else {
        NSArray *list = self.navigationBar.subviews;
        for (id obj in list) {
            if ([obj isKindOfClass:[UIImageView class]]) {
                UIImageView *imageView=(UIImageView *)obj;
                NSArray *list2 = imageView.subviews;
                for (id obj2 in list2) {
                    if ([obj isKindOfClass:[UIImageView class]]) {
                        UIImageView *imageView2 = (UIImageView *)obj2;
                        if (imageView2.frame.size.height < 1.0) {
                            imageView2.hidden = YES;
                        }
                    }
                }
            }
        }
    }
}


@end
